using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UseButton : MonoBehaviour
{
    public ItemUI itemUI;
    public  Inventory inventory;
    
    public void OnClick()
    {
        int id = itemUI.id;
        for (int i = 0; i < inventory.itemList.Count; i++)
        {
            if (inventory.itemList[i].itemSO.itemID == id)
            {
                inventory.itemList[i].itemSO.itemHeld--;
                if (inventory.itemList[i].itemSO.itemHeld <= 0)
                {
                    inventory.itemList.RemoveAt(i);
                    InventoryUI.Instance.InitInv();
                }
                else
                {
                    itemUI.UpdateHeldText(inventory.itemList[i].itemSO);
                }
                break;
            }
        }
    }
}
